package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.vo.SysFeedbackInfoVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysFeedbackInfo;
import com.ruoyi.system.service.ISysFeedbackInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 反馈信息Controller
 *
 * @author ruoyi
 * @date 2025-09-01
 */
@RestController
@RequestMapping("/system/info")
public class SysFeedbackInfoController extends BaseController
{
    @Autowired
    private ISysFeedbackInfoService sysFeedbackInfoService;

    /**
     * 查询反馈信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysFeedbackInfo sysFeedbackInfo)
    {
        startPage();
        List<SysFeedbackInfoVo> list = sysFeedbackInfoService.selectSysFeedbackInfoList(sysFeedbackInfo);
        return getDataTable(list);
    }

    /**
     * 导出反馈信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "反馈信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysFeedbackInfo sysFeedbackInfo)
    {
        List<SysFeedbackInfoVo> list = sysFeedbackInfoService.selectSysFeedbackInfoList(sysFeedbackInfo);
        ExcelUtil<SysFeedbackInfoVo> util = new ExcelUtil<SysFeedbackInfoVo>(SysFeedbackInfoVo.class);
        util.exportExcel(response, list, "反馈信息数据");
    }

    /**
     * 获取反馈信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId)
    {
        return success(sysFeedbackInfoService.selectSysFeedbackInfoByFeedbackId(feedbackId));
    }

    /**
     * 新增反馈信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "反馈信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysFeedbackInfo sysFeedbackInfo)
    {
        return toAjax(sysFeedbackInfoService.insertSysFeedbackInfo(sysFeedbackInfo));
    }

    /**
     * 修改反馈信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "反馈信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysFeedbackInfo sysFeedbackInfo)
    {
        return toAjax(sysFeedbackInfoService.updateSysFeedbackInfo(sysFeedbackInfo));
    }

    /**
     * 删除反馈信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "反馈信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedbackIds}")
    public AjaxResult remove(@PathVariable Long[] feedbackIds)
    {
        return toAjax(sysFeedbackInfoService.deleteSysFeedbackInfoByFeedbackIds(feedbackIds));
    }


    @PreAuthorize("@ss.hasPermi('system:info:appList')")
    @PostMapping("/app_feed_back_list")
    public AjaxResult appFeedBackList(){
        return sysFeedbackInfoService.appFeedBackList();
    }


}
